#include<bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const int N=100010;
int n,m,L,V,k;
int p[N];
int tr[N];
struct node{
    ld d,v,a;
}c[N];
struct Segment{
    int l,r;
    bool operator >(const Segment &b) const{
        return r<b.r;
    }
}seg[N];
bool cmp(Segment x,Segment y){
    return x.r<y.r;
}
int lowbit(int x){
    return x&(-x);
}
void add(int x,int v){
    for(;x<=m;x+=lowbit(x)) tr[x]+=v;
}
int query(int x){
    int res=0;
    for(;x;x-=lowbit(x)) res+=tr[x];
    return res;
}
void solve(){
    cin>>n>>m>>L>>V;
    k=0;
    for(int i=1;i<=m;i++) tr[i]=0;
    for(int i=1;i<=n;i++) cin>>c[i].d>>c[i].v>>c[i].a;
    for(int i=1;i<=m;i++) cin>>p[i];
    for(int i=1;i<=n;i++){
        // cout<<i<<endl;
        if(c[i].a<0){
            int t=lower_bound(p+1,p+1+m,c[i].d)-p;
            int l=lower_bound(p+1,p+1+m,c[i].d)-p,r=m,mid,res=-1;
            while(l<=r){
                mid=(l+r)>>1;
                if(c[i].v*c[i].v+c[i].a*2*(p[mid]-c[i].d)>=0 && (long double)sqrt(c[i].v*c[i].v+c[i].a*2*(p[mid]-c[i].d))>V) res=mid,l=mid+1;
                else r=mid-1;
            }
            // cout<<res<<endl;
            if(res!=-1){
                seg[++k]=Segment{t,res};
            }
        }
        else{
            int l=lower_bound(p+1,p+1+m,c[i].d)-p,r=m,mid,res=-1;
            while(l<=r){
                mid=(l+r)>>1;
                if(sqrt(c[i].v*c[i].v+c[i].a*2*(p[mid]-c[i].d))>V) res=mid,r=mid-1;
                else l=mid+1;
            }
            // cout<<res<<endl;
            if(res!=-1){
                seg[++k]=Segment{res,m};
            }
        }
    }
    sort(seg+1,seg+1+k,cmp);
    int ans=0;
    for(int i=1;i<=k;i++){
        // cout<<seg[i].l<<' '<<seg[i].r<<endl;
        if(query(seg[i].r)-query(seg[i].l-1)==0) ans++,add(seg[i].r,1);
    }
    cout<<k<<' '<<m-ans<<endl;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int T;
    cin>>T;
    while(T--)
        solve();
    return 0;
}
//100